package com.zsrt.common.listener;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class ScottHttpSessionListener implements HttpSessionListener {

	/**
	 * 当创建session的时候会调用此方法...
	 */
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		
		//当一个用户请求过来的时候会调用此方法?
		
		//把用户数+1  用户数保存在application
		
		System.out.println("进入session的方法....");
		
		ServletContext application = se.getSession().getServletContext();
		Integer old  =  (Integer) application.getAttribute("counter");
		application.setAttribute("counter", old+1);
		

	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {

	}

}
